package com.hdoit.apollo.logical.cargo.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.hdoit.apollo.logical.cargo.dao.IStandardUserDao;
import com.hdoit.apollo.logical.cargo.model.Collocation;
import com.hdoit.apollo.logical.cargo.model.StandardPropertyUser;
import com.hdoit.apollo.logical.cargo.model.StandardUser;
import com.hdoit.apollo.logical.cargo.service.ICollocationService;
import com.hdoit.apollo.logical.cargo.service.IStandardPropertyUserService;
import com.hdoit.apollo.logical.cargo.service.IStandardUserService;
import com.hdoit.apollo.logical.stock.model.StockCollocation;
import com.hdoit.apollo.logical.stock.service.IStockCollocationService;
import com.tennetcn.data.dao.base.impl.SuperService;
/**
 * @author      humaoshu
 * @email       
 * @createtime  2018年04月02日 11:03:14
 * @comment
 */
@Component
public class StandardUserServiceImpl extends SuperService<StandardUser> implements IStandardUserService{

	@Autowired
	private IStandardUserDao standardUserDao;
	
	
	@Autowired
	private IStandardUserService standardUserService;
	
	@Autowired
	private IStandardPropertyUserService standardPropertyUserService;
	
	@Autowired
	private ICollocationService collocationService;
	
	
	
	@Autowired
	private IStockCollocationService stockCollocationService;
	
	
	@Override
	public List<StandardUser> queryListByCargoId(String cargoId) {
		
		return standardUserDao.queryListByCargoId(cargoId);
	}

	@Override
	public boolean saveStandardsAbout(List<StandardUser> standardUsers,
			List<Collocation> collocations2,
			List<StandardPropertyUser> standardPropertyUsers,
			List<StockCollocation> stockCollocations) {
		if(super.applyChanges(standardUsers)){
			System.err.println(standardUsers.size()+"我是规格使用");
			standardUserService.applyChanges(standardUsers);
			standardPropertyUserService.applyChanges(standardPropertyUsers);
			
			collocationService.applyChanges(collocations2);
			
			return stockCollocationService.applyChanges(stockCollocations);

		}
		return false;
	}

	@Override
	public StandardUser queryModelByCargoIdAndStandardId(String cargoId,
			String standardId) {
		
		return standardUserDao.queryModelByCargoIdAndStandardId(cargoId,standardId);
	}

}